package com.cjq.jwt;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@ConfigurationProperties("jwt")
@Data
public class JwtProperties {
    /**
     * Token名称
     */
    private String tokenName = "token";
    /**
     * 密钥
     */
    private String secretKey;
    /**
     * 过期时间(s)
     */
    private int expiration = 3600;
    /**
     * 签发者
     */
    private String issUser = "server";
    /**
     * 主题
     */
    private String subject = "system";
    /**
     * 目标受众
     */
    private String audience = "browser";

    public void validate(){
        if (secretKey == null || secretKey.isEmpty()) {
            throw new IllegalArgumentException("JWT secret key cannot be null or empty");
        }
    }
}
